from django.shortcuts import render

# Create your views here.
from rest_framework.views import APIView
from .models import *
from rest_framework.response import Response

class FilmView(APIView):
    def get(self,request):
        film_data = Film.objects.all()
        list = []
        for i in film_data:
            list.append({
                'id':i.id,
                'name':i.name,
                'dir':i.dir,
                'star':i.star,
                'item':i.item,
                'img':i.img,
                'score':i.score,
                'kind':i.kind.id,
                'kind_name':i.kind.name,

            })
        return Response({'code':200,'msg':'成功','film':list})

class CateView(APIView):

    def get(self,request):
        kind_data = Cate.objects.all()
        lst = []
        for i in kind_data:
            lst.append({
                'id':i.id,
                'name':i.name,
            })
        return Response({'code':200,'msg':'成功','kind':lst})